package controller;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;

import javax.swing.JButton;

import model.Kunde;

import view.MainWindow;
import view.ModifyCustomerView;

public class GUIModifyCustomerViewController implements ActionListener
{
	private ModifyCustomerView cv;
	private ArrayList<Kunde> list;
	private ArrayList<JButton> btnlist;
	
	private Container cont;

	public GUIModifyCustomerViewController(Container cont)
	{
		super();
		Kunde c1 = new Kunde("Clemens", " Maier", "musterweg 23", "thefirm", "stammgast", 10L, "4424", "clemens@clemens.at", "www.cl.at", "356323", new Date(),
				null);
		Kunde c2 = new Kunde("Max", " Maier", "weg 23", "firma0815", "stammgast 10jahre", 20L, "4444", "clemens@clemens.at", "www.cl333.at", "356323213223",
				new Date(), null);
		list = new ArrayList<Kunde>();
		list.add(c1);
		list.add(c2);
		this.cont = cont;
		this.cv = new ModifyCustomerView(cont, list);
		this.cv.addActionsListeners(this);
	}


	@Override
	public void actionPerformed(ActionEvent e)
	{
		this.btnlist=this.cv.getBtnlist();
		Iterator<JButton>itr =btnlist.iterator();
		int i = 0;
		while(itr.hasNext()){
			JButton btn = itr.next();
			if(e.getSource()==btn){
				this.cont.removeAll();
				System.out.println(this.list.get(i).toString());
				 GUIModifyUserInDetailContoller gmcvc = new GUIModifyUserInDetailContoller(cont,this.list.get(i));
				 
				 this.cont.add(gmcvc.getMud());
				 System.out.println("Hello");
				 this.cont.validate();
				 this.cont.repaint();
				
			}
			i++;
		}
		
		
	}


	public ModifyCustomerView getCv()
	{
		return cv;
	}


	public void setCv(ModifyCustomerView cv)
	{
		this.cv = cv;
	}



	

}
